package com.ozo.boot.system.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ozo.boot.common.base.model.*;
import com.ozo.boot.common.base.model.BasePage;
import com.ozo.boot.common.base.model.PageResult;
import com.ozo.boot.common.base.model.ResultVO;
import com.ozo.boot.common.log.annotation.OperateLog;
import com.ozo.boot.system.pojo.dto.SysOperationLogQueryDTO;
import com.ozo.boot.system.pojo.vo.SysOperationLogVO;
import com.ozo.boot.system.service.ISysOperationLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

/**
 * 操作日志 前端控制器
 *
 * @author qiangesoft
 * @version 1.0
 * @date 2024-11-20 10:47:15
 */
@Tag(name = "操作日志")
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/operationLog")
public class SysOperationLogController {

    private final ISysOperationLogService sysOperationLogService;

    @OperateLog(value = "删除操作日志", module = "操作日志")
    @SaCheckPermission("system:operationLog:remove")
    @Operation(summary = "删除操作日志")
    @DeleteMapping("/remove")
    public ResultVO<Void> remove(@RequestBody @Valid BaseBatchDTO<Long> batchDTO) {
        sysOperationLogService.remove(batchDTO);
        return ResultVO.success();
    }

    @OperateLog(value = "清空操作日志", module = "操作日志")
    @SaCheckPermission("system:operationLog:clear")
    @Operation(summary = "清空操作日志")
    @DeleteMapping("/clear")
    public ResultVO<Void> clear() {
        sysOperationLogService.clear();
        return ResultVO.success();
    }

    @SaCheckPermission("system:operationLog:page")
    @Operation(summary = "操作日志分页")
    @GetMapping("/page")
    public ResultVO<PageResult<SysOperationLogVO>> page(@Valid BasePage basePage, SysOperationLogQueryDTO queryDTO) {
        return ResultVO.success(sysOperationLogService.page(basePage, queryDTO));
    }

}